<template>
  <div class="box" >
    <h1>组件2{{msg}}</h1>
   <router-link to="/">首页</router-link>
   <router-link to="/vuexc">组件1</router-link>
    <router-link to="/vuexc2">组件2</router-link>
   <h1>{{count}}</h1>
   <button @click="minus">减少</button>
 </div>
  </template>
  <script>
  export default {
    name: 'vuexc',
    data() {
      return {
        msg: 'vuex'
      }
    },
 computed:{
   count:function(){ return  this.$store.state.count },
    getlogin:function(){ return this.$store.getters.getlogin}
  },

  methods:{
    almuta(opt){
      this.$store.dispatch('almuta',opt)
    },
    alstate(opt){
      this.$store.commit('alterLogin',opt)
   },
   minus(){
     this.msg+=1;
     this.$store.dispatch("minusone");
   }
  }
  }
  </script>
